﻿using System.Linq;
using System.Collections.Generic;
using INHollandair.Core.Models;
using INHollandair.Core.Repositories;

namespace INHollandair.Core.Services
{
    public class OrderService
    {
        private readonly OrderRepository _repo = new OrderRepository();

        public bool OrderExisting(int id)
        {
            return _repo.OrderRepo.Any(x => x.ID.Equals(id));
        }
        public Order GetOrderById(int id)
        {
            return _repo.OrderRepo.FirstOrDefault(x => x.ID.Equals(id));
        }
        public Order GetOrderByUrl(string url)
        {
            return _repo.OrderRepo.FirstOrDefault(x => x.OrderURL.Equals(url));
        }
        public List<OrderHistory> GetOrdersByUserId(int userId)
        {
            return _repo.OrderHistoryRepo.Where(x => x.UserID.Equals(userId)).ToList();
        }
        public void InsertOrder(Order order)
        {
            _repo.InsertOrder(order);
        }
        public void UpdateOrder(Order order)
        {
            _repo.UpdateOrder(order);
        }
        public void RemoveOrder(Order order)
        {
            _repo.RemoveOrder(order);
        }
    }
}
